<template>
  <div>
      <section ref="print">
        <el-row :gutter="6">
            <el-col :span="9">
              <el-form-item label="客户：">
                    {{customerName}}
              </el-form-item>
            </el-col>
            <el-col :span="6">
              &nbsp;
            </el-col>
            <el-col :span="9">
              <el-form-item label="打印日期：">
                    {{systemDate}}
              </el-form-item>
            </el-col>
        </el-row>
        <el-table :data="printData" border style="margin-left:30px;width: 90%">
          <el-table-column
            prop="sorted"
            label="序号"
            width="180">
          </el-table-column>
          <el-table-column
            prop="trackingNo"
            label="追踪号"
            width="180">
          </el-table-column>
          <el-table-column
            prop="orderNo"
            label="内部单号">
          </el-table-column>
          <el-table-column
            prop="returnTypeStr"
            label="退件类型">
          </el-table-column>
          <el-table-column
            prop="returnRemark"
            label="退件原因">
          </el-table-column>
          <el-table-column
            prop="orderPiece"
            label="件数">
          </el-table-column>
      </el-table>
      <el-row :gutter="19">
            <el-col :span="9">
              &nbsp;
            </el-col>
            <el-col :span="6">
              &nbsp;
            </el-col>
            <el-col :span="9">
              <el-form-item label="合计：">
                    {{totalorderPiece}}
              </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="6">
            <el-col :span="4">
             &nbsp;
            </el-col>
            <el-col :span="11">
              操作人：
            </el-col>
            <el-col :span="9">
              <span>收货人签字：</span>
            </el-col>
        </el-row>
      </section>  
  </div>
</template>
<script>
import {ajax} from "@/store/yg/common/utils";
import {m,f} from "@/store/yg/common/local"
export default {
  components: {},
  props: [　'row', 'data', 'more'],
  data() {
    return {
      customerName: '',
      systemDate:'',
      totalorderPiece: 0,
      printData:[],
      rules: {
        orderNo: [{
          required: true,
          message: '请扫描或输入运单号/追踪号',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    this.initData()
  },
  methods: {
    initData() {
      //选中的ID
      const ids = this.$store.state.main.selectedRows
      //页面所有的数据
      const pageData = this.$store.state.main.pageData.data
      
      //开始解析数据
      var sorted = 1;
      //总件数
      var totalorderPiece = 0;
      var options = this.$store.state.main.entry.sources['customerSource'];
      let  nowDate = new Date();
      let date = {
        year: nowDate.getFullYear(),
        month: nowDate.getMonth() + 1,
        date: nowDate.getDate(),
      }
      console.log(date);
      this.systemDate = date.year + '-'  + date.month + '-'  + date.date;              
      pageData.forEach(item =>{
           var dataId = item.id
           var indexId = ids.indexOf(dataId) 
           if(indexId != -1){
             item["sorted"] = 1
             sorted = sorted + 1
             if(item.returnType !=null){
                var customerId = item["customerId"]
                if(customerId != null){
                    this.customerName = options[customerId]
                }
                if(item.returnType === 0 ){
                     item["returnTypeStr"] = "国外退件"
                }
                if(item.returnType === 1){
                    item["returnTypeStr"] = "国内退件"
                }
                if(item.returnType === 2){
                    item["returnTypeStr"] = "客户退件"
                }
             }
             if(item["orderPiece"] != null ){
                this.totalorderPiece = this.totalorderPiece + item["orderPiece"]
             }
             this.printData.push(item)
          }
        })
    },
  }
}

</script>
<style>
</style>
